package crs.perfiles.dao;
// default package
// Generated 24-ene-2015 20:59:54 by Hibernate Tools 4.3.1

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import crs.perfiles.model.CrsPerfilComercial;

/**
 * Home object for domain model class CrsPerfilComercial.
 * @see .CrsPerfilComercial
 * @author Hibernate Tools
 */
@Repository
public class CrsPerfilComercialDaoImpl  implements CrsPerfilComercialDao{
	
	private static final Log log = LogFactory
			.getLog(CrsPerfilComercialDaoImpl.class);

	@Autowired
	private SessionFactory sf;

	public void persist(CrsPerfilComercial transientInstance) {
		log.debug("persisting CrsPerfilComercial instance");
		try {
			sf.getCurrentSession().persist(transientInstance);
			log.debug("persist successful");
		} catch (RuntimeException re) {
			log.error("persist failed", re);
			throw re;
		}
	}

	public void remove(CrsPerfilComercial persistentInstance) {
		log.debug("removing CrsPerfilComercial instance");
		try {
			sf.getCurrentSession().delete(persistentInstance);
			log.debug("remove successful");
		} catch (RuntimeException re) {
			log.error("remove failed", re);
			throw re;
		}
	}

	public CrsPerfilComercial merge(CrsPerfilComercial detachedInstance) {
		log.debug("merging CrsPerfilComercial instance");
		try {
			CrsPerfilComercial result = (CrsPerfilComercial) sf.getCurrentSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public CrsPerfilComercial findById(int id) {
		log.debug("getting CrsPerfilComercial instance with id: " + id);
		try {
			CrsPerfilComercial instance = (CrsPerfilComercial) sf.getCurrentSession().get(
					CrsPerfilComercial.class, id);
			log.debug("get successful");
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
}
